package gov.pbc.gx.nn.pz.impl;

import gov.pbc.gx.nn.pz.dao.ZwtzpzDao;
import gov.pbc.gx.nn.pz.entity.Account;
import gov.pbc.gx.nn.pz.entity.HcZwtzpz;
import gov.pbc.gx.nn.pz.entity.HcpzXY;
import gov.pbc.gx.nn.pz.entity.PzFont;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;
import javax.imageio.ImageIO;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.bstek.bdf2.core.business.IUser;
import com.bstek.bdf2.core.context.ContextHolder;
import com.bstek.bdf2.core.exception.NoneLoginException;
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.bstek.dorado.annotation.Expose;
import com.bstek.dorado.data.entity.EntityUtils;
import com.bstek.dorado.data.variant.Record;
import com.bstek.dorado.web.DoradoContext;

@Component("zwtzpzPR")
public class ZwtzpzPR {

	private Integer PZ_CODE_ = 6;
	private static final Integer Font_Size = 16;

	@Resource
	@Autowired
	private ZwtzpzDao zwtzpzDao;

	@Transactional
	@DataProvider
	public Record getZwtzpzs() {
		try {
			IUser loginuser = ContextHolder.getLoginUser();
			if (loginuser == null)
				return null;
			if (loginuser.getDepts() == null
					|| loginuser.getDepts().size() <= 0)
				return null;

			Record record = new Record();
			record.put("pzdate", new Date());
			Collection<HcZwtzpz> lists = zwtzpzDao.getMuByDeptName();
			if (lists.isEmpty()) {
				HcZwtzpz e = new HcZwtzpz();
				e.setPzDate(new Date());
				e.setPzTemplate("新建模板");
				lists.add(e);
				record.put("zwtzpz", lists);
			} else {
				for (HcZwtzpz zwt : lists) {
					zwt.setPzDate(new Date());
				}
				record.put("zwtzpz", lists);
			}

			List<HcpzXY> zwtzpzXYs = zwtzpzDao.getZwtzpzXYs(PZ_CODE_);
			if (zwtzpzXYs != null && !zwtzpzXYs.isEmpty()) {
				record.put("pys", zwtzpzXYs);
			} else {
				zwtzpzXYs = new ArrayList<HcpzXY>();
				HcpzXY zwtzpzXY = new HcpzXY();

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("页边距", 50, 50, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setId(UUID.randomUUID().toString());
				zwtzpzXY.setProperty("年", 260, 76, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("月", 339, 76, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("日", 400, 76, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("原业务流水号", 135, 100, 14);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("原账务日期", 515, 100, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("附件数量", 704, 255, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("业务种类", 154, 133, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("账户名称1", 140, 177, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("账户账号1", 140, 210, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("借贷标记1", 410, 182, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("小写金额1", 688, 210, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("账户名称2", 140, 247, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("账户账号2", 140, 280, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("借贷标记2", 410, 252, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("小写金额2", 688, 280, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("账户名称3", 140, 317, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("账户账号3", 140, 348, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("借贷标记3", 410, 321, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

				zwtzpzXY = new HcpzXY();
				zwtzpzXY.setProperty("小写金额3", 688, 350, Font_Size);
				zwtzpzXYs.add(zwtzpzXY);

			}
			record.put("pys", zwtzpzXYs);

			return record;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return null;
		}
	}

	@SuppressWarnings("unchecked")
	private void setImageData(Graphics2D graphics, Map<String, Object> param) {
		try {
			HcZwtzpz zwtzpz = (HcZwtzpz) param.get("zwtzpz");
			Date pzdate = (Date) param.get("pzdate");

			int hongziPrint = EntityUtils.getValue(zwtzpz, "hongziPrint");

			String cnFont = param.get("cnFont").toString();
			String numFont = param.get("numFont").toString();

			int pyx = (int) Integer.parseInt(param.get("x").toString());
			int pyy = (int) Integer.parseInt(param.get("y").toString());

			graphics.setBackground(Color.WHITE);
			graphics.setColor(Color.BLACK);
			// Font zhFont = new Font(cnFont, Font.PLAIN, 16);
			// Font enFont = new Font(numFont, Font.PLAIN, 16);
			// Font oldFont = new Font(numFont, Font.PLAIN, 14);

			List<HcpzXY> HcZwtzpz = (List<HcpzXY>) param.get("pys");

			for (HcpzXY pym : HcZwtzpz) {

				int x = pym.getX() + pyx;
				int y = pym.getY() + pyy;
				int size = pym.getFontSize();
				String lable = pym.getLabel();

				if (pzdate != null) {
					Calendar calendar = Calendar.getInstance();
					calendar.setTime(pzdate);

					if (lable.equals("年")) {
						Font enFont = new Font(numFont, Font.PLAIN, size);
						graphics.setFont(enFont);
						graphics.drawString(
								String.format("%04d",
										calendar.get(Calendar.YEAR)), x, y);
					}
					if (lable.equals("月")) {
						Font enFont = new Font(numFont, Font.PLAIN, size);
						graphics.setFont(enFont);
						graphics.drawString(
								String.format("%02d",
										calendar.get(Calendar.MONTH) + 1), x, y);
					}
					if (lable.equals("日")) {
						Font enFont = new Font(numFont, Font.PLAIN, size);
						graphics.setFont(enFont);
						graphics.drawString(
								String.format("%02d",
										calendar.get(Calendar.DATE)), x, y);
					}
				}
				if (HcZwtzpz != null) {
					if (lable.equals("附件数量")) {
						if (zwtzpz.getAttachmentCount() != null) {
							Font enFont = new Font(numFont, Font.PLAIN, size);
							graphics.setFont(enFont);
							graphics.drawString(
									String.valueOf(zwtzpz.getAttachmentCount()),
									x, y);
						}
					}
					if (lable.equals("原业务流水号")) {
						if (zwtzpz.getOldSerialNumber() != null) {
							Font oldFont = new Font(numFont, Font.PLAIN, size);
							graphics.setFont(oldFont);
							graphics.drawString(zwtzpz.getOldSerialNumber(), x,
									y);
						}
					}

					if (lable.equals("原账务日期")) {
						if (zwtzpz.getOldZwtzpzDate() != null) {
							Font enFont = new Font(numFont, Font.PLAIN, size);
							graphics.setFont(enFont);
							Calendar calendar = Calendar.getInstance();
							calendar.setTime(zwtzpz.getOldZwtzpzDate());
							graphics.drawString(
									String.format("%04d",
											calendar.get(Calendar.YEAR)), x, y);
							graphics.drawString(
									String.format("%02d",
											calendar.get(Calendar.MONTH) + 1),
									x + 63, y);
							graphics.drawString(
									String.format("%02d",
											calendar.get(Calendar.DATE)),
									x + 108, y);
						}
					}
					if (lable.equals("业务种类")) {
						if (zwtzpz.getBusinessTypes() != null) {
							Font zhFont = new Font(cnFont, Font.PLAIN, size);
							graphics.setFont(zhFont);
							String[] nums = zwtzpz.getBusinessTypes()
									.split(",");
							String click = "√";
							if (nums != null) {
								if (Integer.parseInt(nums[0]) == 1) {
									graphics.drawString(click, x, y + 3);
								}
								if (Integer.parseInt(nums[1]) == 1) {
									graphics.drawString(click, x + 60, y + 3);
								}
								if (Integer.parseInt(nums[2]) == 1) {
									graphics.drawString(click, x + 121, y + 3);
								}
								if (Integer.parseInt(nums[3]) == 1) {
									graphics.drawString(click, x + 203, y + 3);
								}
								if (Integer.parseInt(nums[4]) == 1) {
									graphics.drawString(click, x + 287, y + 3);
								}
								if (Integer.parseInt(nums[5]) == 1) {
									graphics.drawString(click, x + 372, y + 3);
								}
								if (Integer.parseInt(nums[6]) == 1) {
									graphics.drawString(click, x + 455, y + 3);
								}
							}
						}
					}
					if (lable.equals("账户名称1")) {
						if (zwtzpz.getZhNameOne() != null) {
							Font zhFont = new Font(cnFont, Font.PLAIN, size);
							graphics.setFont(zhFont);
							graphics.drawString(zwtzpz.getZhNameOne(), x, y);
						}

					}
					if (lable.equals("账户账号1")) {
						if (zwtzpz.getZhUsernameOne() != null) {
							Font enFont = new Font(numFont, Font.PLAIN, size);
							graphics.setFont(enFont);
							graphics.drawString(zwtzpz.getZhUsernameOne(), x, y);
						}

					}
					if (lable.equals("借贷标记1")) {
						if (zwtzpz.getLendTagOne() != null) {
							Font zhFont = new Font(cnFont, Font.PLAIN, size);
							graphics.setFont(zhFont);
							String click = "√";
							if (Integer.parseInt(zwtzpz.getLendTagOne()) == 0) {
								graphics.drawString(click, x, y);
							}
							if (Integer.parseInt(zwtzpz.getLendTagOne()) == 1) {
								graphics.drawString(click, x, y + 14);
							}

						}

					}

					if (lable.equals("账户名称2")) {
						if (zwtzpz.getZhNameTwo() != null) {
							Font zhFont = new Font(cnFont, Font.PLAIN, size);
							graphics.setFont(zhFont);
							graphics.drawString(zwtzpz.getZhNameTwo(), x, y);
						}

					}
					if (lable.equals("账户账号2")) {
						if (zwtzpz.getZhUsernameTwo() != null) {
							Font enFont = new Font(numFont, Font.PLAIN, size);
							graphics.setFont(enFont);
							graphics.drawString(zwtzpz.getZhUsernameTwo(), x, y);
						}

					}
					if (lable.equals("借贷标记2")) {
						if (zwtzpz.getLendTagTwo() != null) {
							Font zhFont = new Font(cnFont, Font.PLAIN, size);
							graphics.setFont(zhFont);
							String click = "√";
							if (Integer.parseInt(zwtzpz.getLendTagTwo()) == 0) {
								graphics.drawString(click, x, y);
							}
							if (Integer.parseInt(zwtzpz.getLendTagTwo()) == 1) {
								graphics.drawString(click, x, y + 14);
							}

						}

					}
					if (lable.equals("账户名称3")) {
						if (zwtzpz.getZhNameThree() != null) {
							Font zhFont = new Font(cnFont, Font.PLAIN, size);
							graphics.setFont(zhFont);
							graphics.drawString(zwtzpz.getZhNameThree(), x, y);
						}

					}
					if (lable.equals("账户账号3")) {
						if (zwtzpz.getZhUsernameThree() != null) {
							Font enFont = new Font(numFont, Font.PLAIN, size);
							graphics.setFont(enFont);
							graphics.drawString(zwtzpz.getZhUsernameThree(), x,
									y);
						}

					}
					if (lable.equals("借贷标记3")) {
						if (zwtzpz.getLendTagThree() != null) {
							Font zhFont = new Font(cnFont, Font.PLAIN, size);
							graphics.setFont(zhFont);
							String click = "√";
							if (Integer.parseInt(zwtzpz.getLendTagThree()) == 0) {
								graphics.drawString(click, x, y);
							}
							if (Integer.parseInt(zwtzpz.getLendTagThree()) == 1) {
								graphics.drawString(click, x, y + 14);
							}

						}

					}

					if (hongziPrint != 1) {
						if (lable.equals("小写金额1")) {
							if (zwtzpz.getAmountNum() != null) {
								Font enFont = new Font(numFont, Font.PLAIN,
										size);
								graphics.setFont(enFont);
								DecimalFormat df = new DecimalFormat(".00");
								int endX = x;
								char[] chars;
								if (zwtzpz.getAmountNumIssign() == 0) {
									chars = ("¥" + df.format(
											zwtzpz.getAmountNum()).replace(".",
											"")).toCharArray();

									for (int i = 0; i < chars.length; i++) {
										graphics.drawString(chars[chars.length
												- i - 1]
												+ "", endX - i * 15 - i / 5,
												y - 5);
									}
								}
								if (zwtzpz.getAmountNumIssign() == 1) {
									chars = ("HKD" + df.format(
											zwtzpz.getAmountNum()).replace(".",
											"")).toCharArray();

									for (int i = 0; i < chars.length; i++) {
										graphics.drawString(chars[chars.length
												- i - 1]
												+ "", endX - i * 15 - i / 5,
												y - 5);
									}
								}
								if (zwtzpz.getAmountNumIssign() == 2) {
									chars = ("USD" + df.format(
											zwtzpz.getAmountNum()).replace(".",
											"")).toCharArray();

									for (int i = 0; i < chars.length; i++) {
										graphics.drawString(chars[chars.length
												- i - 1]
												+ "", endX - i * 15 - i / 5,
												y - 5);
									}
								}
								if (zwtzpz.getAmountNumIssign() == 3) {
									chars = (df.format(zwtzpz.getAmountNum())
											.replace(".", "")).toCharArray();

									for (int i = 0; i < chars.length; i++) {
										graphics.drawString(chars[chars.length
												- i - 1]
												+ "", endX - i * 15 - i / 5,
												y - 5);
									}
								}

							}

						}
						if (lable.equals("小写金额2")) {
							if (zwtzpz.getAmountNumTwo() != null) {
								Font enFont = new Font(numFont, Font.PLAIN,
										size);
								graphics.setFont(enFont);
								DecimalFormat df = new DecimalFormat(".00");
								char[] chars;
								int endX = x;
								if (zwtzpz.getAmountNumIssignTwo() == 0) {
									chars = ("¥" + df.format(
											zwtzpz.getAmountNumTwo()).replace(
											".", "")).toCharArray();

									for (int i = 0; i < chars.length; i++) {
										graphics.drawString(chars[chars.length
												- i - 1]
												+ "", endX - i * 15 - i / 5,
												y - 5);
									}
								}
								if (zwtzpz.getAmountNumIssignTwo() == 1) {
									chars = ("HKD" + df.format(
											zwtzpz.getAmountNumTwo()).replace(
											".", "")).toCharArray();

									for (int i = 0; i < chars.length; i++) {
										graphics.drawString(chars[chars.length
												- i - 1]
												+ "", endX - i * 15 - i / 5,
												y - 5);
									}
								}
								if (zwtzpz.getAmountNumIssignTwo() == 2) {
									chars = ("USD" + df.format(
											zwtzpz.getAmountNumTwo()).replace(
											".", "")).toCharArray();

									for (int i = 0; i < chars.length; i++) {
										graphics.drawString(chars[chars.length
												- i - 1]
												+ "", endX - i * 15 - i / 5,
												y - 5);
									}
								}
								if (zwtzpz.getAmountNumIssignTwo() == 3) {
									chars = (df
											.format(zwtzpz.getAmountNumTwo())
											.replace(".", "")).toCharArray();

									for (int i = 0; i < chars.length; i++) {
										graphics.drawString(chars[chars.length
												- i - 1]
												+ "", endX - i * 15 - i / 5,
												y - 5);
									}
								}

							}

						}
						if (lable.equals("小写金额3")) {
							if (zwtzpz.getAmountNumThree() != null) {
								Font enFont = new Font(numFont, Font.PLAIN,
										size);
								graphics.setFont(enFont);
								DecimalFormat df = new DecimalFormat(".00");
								char[] chars;
								int endX = x;
								if (zwtzpz.getAmountNumIssignThree() == 0) {
									chars = ("¥" + df.format(
											zwtzpz.getAmountNumThree())
											.replace(".", "")).toCharArray();

									for (int i = 0; i < chars.length; i++) {
										graphics.drawString(chars[chars.length
												- i - 1]
												+ "", endX - i * 15 - i / 5,
												y - 5);
									}
								}
								if (zwtzpz.getAmountNumIssignThree() == 1) {
									chars = ("HKD" + df.format(
											zwtzpz.getAmountNumThree())
											.replace(".", "")).toCharArray();

									for (int i = 0; i < chars.length; i++) {
										graphics.drawString(chars[chars.length
												- i - 1]
												+ "", endX - i * 15 - i / 5,
												y - 5);
									}
								}
								if (zwtzpz.getAmountNumIssignThree() == 2) {
									chars = ("USD" + df.format(
											zwtzpz.getAmountNumThree())
											.replace(".", "")).toCharArray();

									for (int i = 0; i < chars.length; i++) {
										graphics.drawString(chars[chars.length
												- i - 1]
												+ "", endX - i * 15 - i / 5,
												y - 5);
									}
								}
								if (zwtzpz.getAmountNumIssignThree() == 3) {
									chars = (df.format(zwtzpz
											.getAmountNumThree()).replace(".",
											"")).toCharArray();

									for (int i = 0; i < chars.length; i++) {
										graphics.drawString(chars[chars.length
												- i - 1]
												+ "", endX - i * 15 - i / 5,
												y - 5);
									}
								}

							}

						}
					}

				}
			}

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

	@Expose
	public String getPrintImageAll(Map<String, Object> param) {
		try {
			if (param == null)
				return null;
			IUser loginuser = ContextHolder.getLoginUser();
			if (loginuser == null)
				throw new NoneLoginException("您未登录，请刷新页面后重试！！");
			param.put("x", 0);
			param.put("y", 0);
			BufferedImage imagepz = ImageIO.read(new File(DoradoContext
					.getCurrent().getServletContext()
					.getRealPath("pz/zwtzpz.jpg")));
			Graphics2D graphicspz = (Graphics2D) imagepz.getGraphics();
			setImageData(graphicspz, param);
			// ByteArrayOutputStream bytestreampz=new ByteArrayOutputStream();
			String filename = "pz/temp/all_" + loginuser.getUsername() + ".jpg";
			FileOutputStream fo = new FileOutputStream(new File(DoradoContext
					.getCurrent().getServletContext().getRealPath(filename)));
			ImageIO.write(imagepz, "jpg", fo);
			fo.flush();
			fo.close();
			// String
			// str="data:image/png;base64,"+Base64.encodeBase64String(bytestreampz.toByteArray());
			// System.out.println(str.length()+","+bytestreampz.toByteArray().length);
			return filename;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return null;
		}
	}

	@Expose
	public String getPrintImageData(Map<String, Object> param) {
		try {
			if (param == null)
				return null;
			IUser loginuser = ContextHolder.getLoginUser();
			if (loginuser == null)
				throw new NoneLoginException("您未登录，请刷新页面后重试！！");
			param.put("x", -34);
			param.put("y", -40);
			BufferedImage imagedata = ImageIO.read(new File(DoradoContext
					.getCurrent().getServletContext()
					.getRealPath("pz/zwtzpz.jpg")));
			// System.out.println(imagepz.getWidth()*1.0/96.0*24.5);
			// BufferedImage imagedata= new BufferedImage(imagepz.getWidth(),
			// imagepz.getHeight(), imagepz.getType());
			Graphics2D graphicsdata = (Graphics2D) imagedata.getGraphics();
			graphicsdata.setBackground(Color.WHITE);

			// 打印背景图片
			graphicsdata.clearRect(0, 0, imagedata.getWidth(),
					imagedata.getHeight());
			setImageData(graphicsdata, param);
			// ByteArrayOutputStream bytestreampz=new ByteArrayOutputStream();
			String filename = "pz/temp/data_" + loginuser.getUsername()
					+ ".jpg";
			FileOutputStream fo = new FileOutputStream(new File(DoradoContext
					.getCurrent().getServletContext().getRealPath(filename)));
			ImageIO.write(imagedata, "jpg", fo);
			fo.flush();
			fo.close();
			// String
			// str="data:image/png;base64,"+Base64.encodeBase64String(bytestreampz.toByteArray());
			// System.out.println(str.length()+","+bytestreampz.toByteArray().length);
			return filename;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return null;
		}
	}

	@Expose
	public Map<String, Object> getUserInfo() {
		IUser loginuser = ContextHolder.getLoginUser();
		Map<String, Object> userinfo = new HashMap<String, Object>();
		if (loginuser == null) {
			userinfo.put("cname", "");
			userinfo.put("dept", "");
			return userinfo;
		}
		userinfo.put("cname", loginuser.getCname());
		if (loginuser.getDepts() == null || loginuser.getDepts().size() <= 0) {
			userinfo.put("dept", "");
			return userinfo;
		}
		userinfo.put("dept", loginuser.getDepts().get(0).getName());
		return userinfo;
	}

	@DataProvider
	public Collection<HcZwtzpz> getTypeByGroup() {
		return zwtzpzDao.getOneGroupByType();

	}

	@SuppressWarnings("unused")
	@DataProvider
	public Collection<HcZwtzpz> getTepementNameByType(Map<String, Object> param) {
		if (param == null) {
			return null;
		}
		String type = (String) param.get("type");
		return zwtzpzDao.getCoByType(type);
	}

	@Expose
	public HcZwtzpz ajaxselectOneByTypeAndTemplate(Map<String, Object> param) {
		String type = (String) param.get("type");
		String pzTemplate = (String) param.get("pzTemplate");
		if (type == null || pzTemplate == null) {
			return null;
		}
		return zwtzpzDao.selectOneByTypeAndTemplate(type, pzTemplate);

	}

	@DataProvider
	public List<Record> getFonts() {
		return zwtzpzDao.getFonts();

	}

	@DataProvider
	public PzFont getFont() {
		return zwtzpzDao.getFont(PZ_CODE_);
	}

	@Transactional
	@DataResolver
	public void saveZwtzpz(HcZwtzpz zwtzpz) {
		zwtzpzDao.saveZwtzpz(zwtzpz);
	}

	@Transactional
	@DataResolver
	public void saveZwtzpzXY(Collection<HcpzXY> zwtzpz) {
		zwtzpzDao.saveZwtzpzXY(zwtzpz);

	}

	@Transactional
	@DataResolver
	public void saveFont(PzFont pzFont) throws Exception {
		zwtzpzDao.updateFont(pzFont);
	}

	@Expose
	public void deleteTemplateById(String id) {
		if (StringUtils.isEmpty(id)) {
			return;
		}
		zwtzpzDao.deleteTemplateById(id);
	}

	@Expose
	public Account getNameByUserName(Map<String, Object> parameter) {
		String account = (String) parameter.get("account");
		return zwtzpzDao.getAccountName(account);
	}

	@Expose
	public boolean updateTemplateNameDao(Map<String, Object> parameter) {
		String id = (String) parameter.get("id");
		String pzTemplate = (String) parameter.get("pzTemplate");
		return zwtzpzDao.updateTemplateNameDao(pzTemplate, id);
	}

	@Expose
	public boolean updateTemplateTypeDao(Map<String, Object> parameter) {
		String id = (String) parameter.get("id");
		String type = (String) parameter.get("type");
		return zwtzpzDao.updateTemplateTypeDao(type, id);
	}

}